#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Python学习展示项目 - 安装配置文件

这个文件定义了项目的元数据和依赖关系，用于:
- 项目打包和分发
- 依赖管理
- 项目安装
- 开发模式安装
"""

from setuptools import setup, find_packages
import os

# 读取README文件作为长描述
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
    long_description = f.read()

# 读取requirements.txt
with open(os.path.join(here, 'requirements.txt'), encoding='utf-8') as f:
    requirements = [line.strip() for line in f if line.strip() and not line.startswith('#')]

# 读取开发依赖
with open(os.path.join(here, 'requirements-dev.txt'), encoding='utf-8') as f:
    dev_requirements = [line.strip() for line in f if line.strip() and not line.startswith('#') and not line.startswith('-r')]

setup(
    # 项目基本信息
    name="python-learn-show",
    version="1.0.0",
    description="Python学习展示项目 - 涵盖Web框架、异步编程、数据库、机器学习等技术栈",
    long_description=long_description,
    long_description_content_type="text/markdown",
    
    # 作者信息
    author="Python学习者",
    author_email="learner@example.com",
    
    # 项目链接
    url="https://github.com/username/python-learn-show",
    project_urls={
        "Bug Reports": "https://github.com/username/python-learn-show/issues",
        "Source": "https://github.com/username/python-learn-show",
        "Documentation": "https://github.com/username/python-learn-show/blob/main/README.md",
    },
    
    # 包配置
    packages=find_packages(exclude=['tests', 'tests.*', 'docs', 'docs.*']),
    include_package_data=True,
    
    # Python版本要求
    python_requires=">=3.8",
    
    # 核心依赖（精简版，仅包含项目运行必需的库）
    install_requires=[
        # Web框架核心
        "fastapi>=0.104.0",
        "uvicorn[standard]>=0.24.0", 
        "pydantic>=2.5.0",
        
        # 数据库驱动
        "sqlalchemy>=2.0.0",
        "asyncpg>=0.29.0",
        "psycopg2-binary>=2.9.0",
        "motor>=3.3.0",
        "pymongo>=4.6.0",
        "redis>=5.0.0",
        "aioredis>=2.0.0",
        
        # 基础科学计算
        "numpy>=1.24.0",
        "pandas>=2.1.0",
        
        # 系统工具
        "psutil>=5.9.0",
        "requests>=2.31.0",
        "python-dotenv>=1.0.0",
        
        # 异步支持
        "aiofiles>=23.2.0",
    ],
    
    # 可选依赖（按功能分类）
    extras_require={
        "dev": [
            # 代码质量工具
            "black>=23.11.0",
            "flake8>=6.1.0",
            "mypy>=1.7.0",
            "isort>=5.12.0",
            "bandit>=1.7.0",
            "pre-commit>=3.5.0",
            # 测试框架
            "pytest>=7.4.0",
            "pytest-asyncio>=0.21.0",
            "pytest-cov>=4.1.0",
            "pytest-mock>=3.12.0",
            "factory-boy>=3.3.0",
            "faker>=20.1.0",
            # 开发工具
            "ipython>=8.17.0",
            "jupyter>=1.0.0",
            "rich>=13.7.0",
            "click>=8.1.0",
        ],
        "ml": [
            # 机器学习核心
            "scikit-learn>=1.3.0",
            "scipy>=1.11.0",
            # 深度学习框架
            "tensorflow>=2.14.0",
            "torch>=2.1.0",
            "transformers>=4.35.0",
            # 数据可视化
            "matplotlib>=3.7.0",
            "seaborn>=0.12.0",
        ],
        "advanced": [
            # 消息队列
            "celery>=5.3.0",
            "kombu>=5.2.0",
            # 图像处理
            "opencv-python>=4.7.0",
            "Pillow>=10.1.0",
            # Excel处理
            "openpyxl>=3.1.0",
            "xlsxwriter>=3.0.0",
            # 高级HTTP
            "httpx>=0.25.0",
            "aiohttp>=3.9.0",
            # 数据库迁移
            "alembic>=1.13.0",
        ],
        "docs": [
            "sphinx>=7.2.0",
            "sphinx-rtd-theme>=1.3.0",
            "mkdocs>=1.5.0",
            "mkdocs-material>=9.4.0",
            "sphinx-autodoc-typehints>=1.22.0",
        ],
        "monitoring": [
            "prometheus-client>=0.19.0",
            "grafana-api>=1.0.3",
            "sentry-sdk>=1.38.0",
            "loguru>=0.7.0",
            "structlog>=23.2.0",
        ],
        "config": [
            "pydantic-settings>=2.1.0",
            "PyYAML>=6.0.0",
            "toml>=0.10.0",
        ],
        "all": [
            # 包含所有可选依赖
            "black>=23.11.0", "flake8>=6.1.0", "mypy>=1.7.0", "isort>=5.12.0",
            "bandit>=1.7.0", "pre-commit>=3.5.0", "pytest>=7.4.0", "pytest-asyncio>=0.21.0",
            "pytest-cov>=4.1.0", "pytest-mock>=3.12.0", "factory-boy>=3.3.0", "faker>=20.1.0",
            "ipython>=8.17.0", "jupyter>=1.0.0", "rich>=13.7.0", "click>=8.1.0",
            "scikit-learn>=1.3.0", "scipy>=1.11.0", "tensorflow>=2.14.0", "torch>=2.1.0",
            "transformers>=4.35.0", "matplotlib>=3.7.0", "seaborn>=0.12.0",
            "celery>=5.3.0", "kombu>=5.2.0", "opencv-python>=4.7.0", "Pillow>=10.1.0",
            "openpyxl>=3.1.0", "xlsxwriter>=3.0.0", "httpx>=0.25.0", "aiohttp>=3.9.0",
            "alembic>=1.13.0", "sphinx>=7.2.0", "sphinx-rtd-theme>=1.3.0", "mkdocs>=1.5.0",
            "mkdocs-material>=9.4.0", "prometheus-client>=0.19.0", "grafana-api>=1.0.3",
            "sentry-sdk>=1.38.0", "loguru>=0.7.0", "structlog>=23.2.0",
            "pydantic-settings>=2.1.0", "PyYAML>=6.0.0", "toml>=0.10.0",
        ],
    },
    
    # 命令行工具
    entry_points={
        'console_scripts': [
            'python-learn-show=main:main',
        ],
    },
    
    # 分类信息
    classifiers=[
        "Development Status :: 4 - Beta",
        "Intended Audience :: Developers",
        "Intended Audience :: Education",
        "Topic :: Software Development :: Libraries :: Python Modules",
        "Topic :: Education",
        "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
        "Topic :: Scientific/Engineering :: Artificial Intelligence",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3.10",
        "Programming Language :: Python :: 3.11",
        "Programming Language :: Python :: 3.12",
        "Operating System :: OS Independent",
    ],
    
    # 关键词
    keywords="python, web, fastapi, django, flask, machine-learning, database, async, education",
    
    # 许可证
    license="MIT",
    
    # 包数据
    package_data={
        '': ['*.txt', '*.md', '*.yml', '*.yaml', '*.json', '*.env.example'],
    },
    
    # 数据文件
    data_files=[
        ('', ['requirements.txt', 'requirements-dev.txt', '.env.example']),
        ('config', ['Makefile', 'Dockerfile', 'docker-compose.yml']),
    ],
    
    # 压缩安全
    zip_safe=False,
)